import os
from os import environ as env

app_env = env.get("APP_ENV", '')
DEBUG = env.get('DEV_ENV')

project_name = os.path.dirname(os.path.abspath(__file__)).split('/')[-1]
project_name_upper = project_name.upper()

# MySQL配置
db_host = env.get('{}_DB_HOST'.format(project_name_upper), '127.0.0.1')
db_port = env.get('{}_DB_PORT'.format(project_name_upper), 3306)
db_name = env.get('{}_DB_NAME'.format(project_name_upper), project_name_upper)
db_user = env.get('{}_DB_USER'.format(project_name_upper), None)
db_pass = env.get('{}_DB_PASSWD'.format(project_name_upper), None)
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'HOST': db_host,
        'PORT': db_port,
        'NAME': db_name,
        'USER': db_user,
        'PASSWORD': db_pass,
        'OPTIONS': {
            'init_command': 'SET storage_engine=INNODB',
        },
    },
}
